﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CounterStrikeSourceAimbot;

namespace CounterStrikeSourceAimbot_WpfControls
{
	/// <summary>
	/// Interaction logic for PersonSymbol.xaml
	/// </summary>
	public partial class PersonSymbol : UserControl
	{
		public PersonSymbol()
		{
			this.InitializeComponent();
		}


	    #region Parent Property and Property Change Routed event

	    public static readonly DependencyProperty ParentProperty
	        = DependencyProperty.Register(
	            "Parent", typeof (MapControl), typeof (PersonSymbol),
	            new PropertyMetadata(null, OnParentChanged, ParentCoerceValue));

	    public MapControl Parent
	    {
	        get { return (MapControl) GetValue(ParentProperty); }
	        set { SetValue(ParentProperty, value); }
	    }

	    public static readonly RoutedEvent ParentChangedEvent
	        = EventManager.RegisterRoutedEvent(
	            "ParentChanged",
	            RoutingStrategy.Direct,
	            typeof (RoutedPropertyChangedEventHandler<MapControl>),
	            typeof (PersonSymbol));

	    private static object ParentCoerceValue(DependencyObject d, object value)
	    {
	        var val = (MapControl) value;
	        var obj = (PersonSymbol) d;


	        return value;
	    }

	    public event RoutedPropertyChangedEventHandler<MapControl> ParentChanged
	    {
	        add { AddHandler(ParentChangedEvent, value); }
	        remove { RemoveHandler(ParentChangedEvent, value); }
	    }

	    private static void OnParentChanged(
	        DependencyObject d,
	        DependencyPropertyChangedEventArgs e)
	    {
	        var obj = d as PersonSymbol;
	        var args = new RoutedPropertyChangedEventArgs<MapControl>(
	            (MapControl) e.OldValue,
	            (MapControl) e.NewValue);
	        args.RoutedEvent = PersonSymbol.ParentChangedEvent;
	        obj.RaiseEvent(args);
	        
	    }


	    #endregion

	    #region Context Property and Property Change Routed event

	    public static readonly DependencyProperty ContextProperty
	        = DependencyProperty.Register(
	            "Context", typeof (PlayerData), typeof (PersonSymbol),
	            new PropertyMetadata(null, OnContextChanged, ContextCoerceValue));

	    public PlayerData Context
	    {
	        get { return (PlayerData) GetValue(ContextProperty); }
	        set { SetValue(ContextProperty, value); }
	    }

	    public static readonly RoutedEvent ContextChangedEvent
	        = EventManager.RegisterRoutedEvent(
	            "ContextChanged",
	            RoutingStrategy.Direct,
	            typeof (RoutedPropertyChangedEventHandler<PlayerData>),
	            typeof (PersonSymbol));

	    private static object ContextCoerceValue(DependencyObject d, object value)
	    {
	        var val = (PlayerData) value;
	        var obj = (PersonSymbol) d;


	        return value;
	    }

	    public event RoutedPropertyChangedEventHandler<PlayerData> ContextChanged
	    {
	        add { AddHandler(ContextChangedEvent, value); }
	        remove { RemoveHandler(ContextChangedEvent, value); }
	    }

	    private static void OnContextChanged(
	        DependencyObject d,
	        DependencyPropertyChangedEventArgs e)
	    {
	        var obj = d as PersonSymbol;
	        var args = new RoutedPropertyChangedEventArgs<PlayerData>(
	            (PlayerData) e.OldValue,
	            (PlayerData) e.NewValue);
	        args.RoutedEvent = PersonSymbol.ContextChangedEvent;
	        obj.RaiseEvent(args);
	        
	    }


	    #endregion
	}
}